package org.springblade.modules.admin.controller.suger;

import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springblade.core.tenant.annotation.TenantIgnore;
import org.springblade.core.tool.api.R;
import org.springblade.modules.admin.dto.sugar.rescue.SugarRescueSearchDTO;
import org.springblade.modules.admin.service.IMaintainMalfunctionRescueService;
import org.springblade.modules.admin.vo.sugar.rescue.*;
import org.springblade.modules.admin.vo.sugar.StatisticsTrendVO;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Date 9:36 2022/10/12
 * @Description {
 *   数据大屏保养管理
 * }
 * @Author lsay
 **/
@RestController
@RequestMapping("/admin/sugar/rescue")
@AllArgsConstructor
@Api(value = "数据大屏保养管理", tags = "数据大屏保养管理")
public class SugarRescueController {

	private final IMaintainMalfunctionRescueService rescueService;


	/**
	 * @Author lsay
	 * @Description {
	 *   高发行政区域
	 * }
	 * @Date 15:44 2023/9/19
	 * @Param
	 * @return
	 **/
	@PostMapping("/area")
	public R<List<RescueAreaVO>> selectRescueArea(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueArea(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   高发时段
	 * }
	 * @Date 15:44 2023/9/19
	 * @Param
	 * @return
	 **/
	@PostMapping("/high/time")
	public R<Map<Integer,Long>> selectRescueHighTime(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueHighTime(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   救援总览
	 * }
	 * @Date 15:45 2023/9/19
	 * @Param
	 * @return
	 **/
	@PostMapping("/overview")
	public R<RescueOverviewVO> selectRescueOverview(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueOverview(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   救援次数及环比
	 * }
	 * @Date 15:45 2023/9/19
	 * @Param
	 * @return
	 **/
	@PostMapping("/count/trend")
	public R<List<StatisticsTrendVO>> selectRescueCountTrend(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueCountTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   救援到达用时雷达图
	 * }
	 * @Date 16:14 2023/9/19
	 * @Param
	 * @return
	 **/
	@PostMapping("/arrive/duration/radar")
	public R<List<Map<String,Object>>> selectRescueArriveDurationRadar(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueArriveDurationRadar(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   救援到达用时合规情况
	 * }
	 * @Date 10:53 2023/9/20
	 * @Param
	 * @return
	 **/
	@PostMapping("/arrive/duration/detail")
	public R<Map<String,Object>> selectRescueArriveDurationDetail(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueArriveDurationDetail(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   超规定时长到达分析
	 * }
	 * @Date 15:45 2023/9/19
	 * @Param
	 * @return
	 **/
	@PostMapping("/arrive/duration/overtime/trend")
	public R<List<StatisticsTrendVO>> selectRescueArriveDurationOvertimeTrend(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueArriveDurationOvertimeTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   响应用时调度
	 * }
	 * @Date 14:47 2023/9/21
	 * @Param
	 * @return
	 **/
	@PostMapping("/allocate/duration/trend")
	public R<Map<String,Object>> selectRescueAllocateDurationTrend(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueAllocateDurationTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   到达现场用时
	 * }
	 * @Date 14:47 2023/9/21
	 * @Param
	 * @return
	 **/
	@PostMapping("/arrive/duration/trend")
	public R<Map<String,Object>> selectRescueArriveDurationTrend(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueArriveDurationTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   完成救援用时
	 * }
	 * @Date 14:47 2023/9/21
	 * @Param
	 * @return
	 **/
	@PostMapping("/work/duration/trend")
	public R<Map<String,Object>> selectRescueWorkDurationTrend(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueWorkDurationTrend(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   困人率
	 * }
	 * @Date 14:24 2023/11/13
	 * @Param
	 * @return
	 **/
	@PostMapping("/tiring/pro")
	public R<StatisticsTrendVO> selectRescueTiringPro(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueTiringPro(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   困人率结果
	 * }
	 * @Date 14:24 2023/11/13
	 * @Param
	 * @return
	 **/
	@PostMapping("/tiring/pro/detail")
	public R<Map<String,Object>> selectRescueTiringProDetail(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectRescueTiringProDetail(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   超规定时长到达明细
	 * }
	 * @Date 14:56 2023/11/13
	 * @Param
	 * @return
	 **/
	@PostMapping("/arrive/duration/overtime/list")
	public R<List<Map<String,Object >>> selectArriveDurationOvertimeList(@RequestBody SugarRescueSearchDTO searchDTO){
		return R.data(rescueService.selectArriveDurationOvertimeList(searchDTO));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   实时救援监控-统计
	 * }
	 * @Date 16:08 2024/4/7
	 * @Param
	 * @return
	 **/
	@GetMapping("/real/time/count")
	public R<RescueRealTimeCountVO> selectRealTimeCount(){
		return R.data(rescueService.selectRealTimeCount());
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   实时救援监控-工单列表
	 * }
	 * @Date 16:08 2024/4/7
	 * @Param
	 * @return
	 **/
	@GetMapping("/real/time/plan/list")
	public R<List<RescueRealTimePlanListVO>> selectRealTimePlanList(Integer planStatus,Integer arrivalWarning){
		return R.data(rescueService.selectRealTimePlanList(planStatus,arrivalWarning));
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   实时救援监控-项目列表
	 * }
	 * @Date 16:08 2024/4/7
	 * @Param
	 * @return
	 **/
	@GetMapping("/real/time/building/list")
	public R<List<RescueRealTimeListVO>> selectRealTimeBuildingList(){
		return R.data(rescueService.selectRealTimeBuildingList());
	}

	/**
	 * @Author lsay
	 * @Description {
	 *   实时救援监控-用户列表
	 * }
	 * @Date 16:08 2024/4/7
	 * @Param
	 * @return
	 **/
	@GetMapping("/real/time/user/list")
	public R<List<RescueRealTimeListVO>> selectRealTimeUserList(){
		return R.data(rescueService.selectRealTimeUserList());
	}

	@TenantIgnore
	@GetMapping("/init")
	public R<?> init(){
		return R.data(rescueService.init());
	}

}
